#include<bits/stdc++.h>
using namespace std;
int main() {
	int n, i, sum = 0, x;
	cin >> n;
	for (i = 1; i <= n; i++) {
		x = i;
		if (x % 7 == 0) continue;
		else {
			while (x) {
				if (x % 10 != 7) x /= 10;
				else break;
			}
			if (!x) sum++;
		}
	}
	cout << sum;
	return 0;
}

